import java.util.EnumMap;


public class EnumMapExample {

  public static void main(String[] args) {
    EnumMap<Car, Integer> cars = new EnumMap<Car, Integer>(Car.class);

    cars.put(Car.BMW, Car.BMW.getPrice());
    cars.put(Car.AUDI, Car.AUDI.getPrice());
    cars.put(Car.MERCEDES, Car.MERCEDES.getPrice());

    for (Car c : cars.keySet())
      System.out.println(c.name());

    System.out.println(cars.size());

    cars.remove(Car.BMW);
    System.out.println("After removing Car.BMW, size: " + cars.size());

    cars.put(Car.valueOf("BMW"), Car.BMW.getPrice());
    System.out.println("Size is now: " + cars.size());
  }

}
